<template>
	<view class="extracurricular">
		<view v-if="activityList.length>0" class="dataList">
			<view class="listitem" v-for="(item,index) in activityList" @click="handleActivedetail(item)">
				<view class="topBox">
					<view class="top_left">
						<image src="../../static/image/qq.png" style="width: 48rpx;height: 48rpx;" mode=""></image>
						<view class="" style="margin-left: 20rpx;">
							{{item.types}}
						</view>
					</view>
					<view v-if="item.status == 1" class="top_right" style="background: #27D8A6;">
						计划中
					</view>
					<view v-if="item.status == 2" class="top_right">
						已参加
					</view>
					<view v-if="item.status == 3" class="top_right" style="background: #FF6F6F;">
						已结束
					</view>

				</view>
				<view class="content">
					<view class="contenttop">
						<view class="lable" style="width: 65%;">
							活动时间
						</view>
						<view v-if="item.type != 'Internship'" class="lable" style="width: 35%;">
							活动名称
						</view>
						<!-- <view class="lable" style="width: 33.33%;">
							比赛结果
						</view> -->

					</view>
					<view v-if="item.type == 'SummerProgram'" class="contentBottom"
						v-for="(subitem,index) in item.children">
						<view class="value" style="width: 65%;">
							{{subitem.summer_start_time}}-{{subitem.summer_end_time}}
						</view>
						<view class="value" style="width: 35%;">
							{{subitem.summer_program}}
						</view>
					</view>
					<view v-if="item.type == 'Competition'" class="contentBottom"
						v-for="(subitem,index) in item.children">
						<view class="value" style="width:65%;">
							{{subitem.competition_time}}
						</view>
						<view class="value" style="width: 35%;">
							{{subitem.competition_type_name}}
						</view>
					</view>
					<view v-if="item.type == 'Research'" class="contentBottom" v-for="(subitem,index) in item.children">
						<view class="value" style="width:65%;">
							{{subitem.research_start_time}}-{{subitem.research_end_time}}
						</view>
						<view class="value" style="width: 35%;">
							{{subitem.research_name}}
						</view>
					</view>
					<view v-if="item.type == 'Volunteer'" class="contentBottom"
						v-for="(subitem,index) in item.children">
						<view class="value" style="width:65%;">
							{{subitem.volunteer_start_time}}-{{subitem.volunteer_end_time}}
						</view>
						<view class="value" style="width: 35%;">
							{{subitem.volunteer_name}}
						</view>
					</view>

					<view v-if="item.type == 'Club'" class="contentBottom" v-for="(subitem,index) in item.children">
						<view class="value" style="width:65%;">
							{{subitem.club_start_time}}-{{subitem.club_end_time}}
						</view>
						<view class="value" style="width: 35%;">
							{{subitem.club_name}}
						</view>
					</view>

					<view v-if="item.type == 'Internship'" class="contentBottom"
						v-for="(subitem,index) in item.children">
						<view class="value" style="width:65%;">
							{{subitem.internship_start_time}}-{{subitem.internship_end_time}}
						</view>
						<!-- <view class="value" style="width: 35%;">
							{{subitem.name}}
						</view> -->
					</view>

					<view v-if="item.type == 'Others'" class="contentBottom" v-for="(subitem,index) in item.children">
						<view class="value" style="width:65%;">
							{{subitem.others_start_time}}-{{subitem.others_end_time}}
						</view>
						<view class="value" style="width: 35%;">
							{{subitem.others_name}}
						</view>
					</view>


				</view>
				<view class="heng"></view>
				<view class="footerBox">
					<view class="">
						查看详情
					</view>
					<u-icon name="arrow-right-double" color="#CCCCCC" size="20"></u-icon>
				</view>
			</view>
		</view>

		<view v-if="activityList.length==0" class="nullBox">
			<image src="../../static/image/nullimg.png" style="width: 148rpx;height: 148rpx;" mode=""></image>
			<view class="">
				暂无活动
			</view>
		</view>

		<view class="" style="height: 100rpx;"></view>

	</view>
</template>

<script>
	import {
		userActivity
	} from "@/api/api.js"
	export default {
		data() {
			return {
				pageId: "",
				activityList: [],
			}
		},
		onLoad(options) {
			this.pageId = options.id
			this.handleuserActivity()
		},
		onPullDownRefresh() {
			// console.log("触发了下拉刷新"),
			this.handleuserActivity()
			uni.stopPullDownRefresh();
		},
		methods: {
			async handleuserActivity() {
				let res = await userActivity({
					page: 1,
					page_size: 10,
					id: this.pageId
				})
				this.activityList = res.data
				this.activityList.forEach((item, index) => {
					if (item.type == "SummerProgram") {
						item.types = "Summer" + " " + "Program"
					} else {
						item.types = item.type
					}
				})
				// console.log("课外活动", res)
			},
			handleActivedetail(item) {
				uni.navigateTo({
					url: `./activeDetail?id=${item.id}`
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.extracurricular {
		.nullBox {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #AEB8C2;
			line-height: 28rpx;
			width: 148rpx;
			text-align: center;
			margin: 0 auto;
			margin-top: 200rpx;
		}

		.dataList {
			width: 690rpx;
			margin: 0 auto;
			margin-top: 30rpx;

			.listitem {
				width: 690rpx;
				// height: 354rpx;
				background: #FFFFFF;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				margin-bottom: 30rpx;

				.topBox {
					width: 690rpx;
					height: 92rpx;
					background: #E1E8FD;
					border-radius: 16rpx 16rpx 0 0;
					padding: 22rpx 20rpx;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					font-size: 32rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					color: #255A9B;
					line-height: 32rpx;
					justify-content: space-between;

					.top_left {
						display: flex;
						align-items: center;
					}

					.top_right {
						width: 92rpx;
						height: 44rpx;
						background: #8BBEFD;
						border-radius: 22rpx 22rpx 22rpx 22rpx;
						font-size: 24rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
						line-height: 44rpx;
						text-align: center;
					}
				}

				.content {
					padding: 30rpx;
					box-sizing: border-box;

					.contenttop {
						display: flex;
						text-align: center;

						.lable {
							width: 33.33%;
							font-size: 28rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #232832;
							line-height: 36rpx;
						}

					}

					.contentBottom {
						display: flex;
						margin-top: 30rpx;

						.value {
							font-size: 28rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #9E9E9E;
							line-height: 36rpx;
							width: 33.33%;
							text-align: center;
						}
					}
				}

				.heng {
					width: 650rpx;
					height: 1rpx;
					background-color: #F4F4F7;
					margin: 0 auto;
				}

				.footerBox {
					padding: 30rpx 60rpx;
					box-sizing: border-box;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #CCCCCC;
					line-height: 28rpx;
				}

			}
		}

	}
</style>